/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.gis.service.dto;

import com.alibaba.fastjson.JSONArray;
import lombok.Data;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import me.zhengjie.utils.map.LonlatConver;

/**
* @website https://el-admin.vip
* @description /
* @author ZhuangBing Yan
* @date 2022-08-19
**/
@Data
public class TimeLineDto implements Serializable {

    /** 主表主键ＩＤ */
    /** 防止精度丢失 */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long id;

    /** 进厂时间 */
    private Timestamp enterInTime;

    /** 路经线坐标 */
    private String linePosition;


    public List<BigDecimal[]> getPoline(){
        return JSONArray.parseArray(this.linePosition,BigDecimal[].class);
    }



    public List<double[]> getPolineWgs84(){
        List<BigDecimal[]> parseArray = JSONArray.parseArray(this.linePosition, BigDecimal[].class);
        List<double[]> wgs84  = new ArrayList<>();
        for(BigDecimal[] ele:parseArray){
            double[] doubles = LonlatConver.gcj02_To_Wgs84(ele[0].doubleValue(), ele[1].doubleValue());
            wgs84.add(new double[] { doubles[1], doubles[0] });
        }
        return wgs84;


    }
}